package com.bw.controller;

import com.bw.bean.Sugar1;
import com.bw.bean.Sugar2;
import com.bw.service.SugarService;
import com.bw.service.SugarServiceImpl;
import com.sugar.SugarUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RestController
public class SugarController {
    @Autowired
    SugarServiceImpl sugarService;

    @RequestMapping("/list1")
    public Map getList1(){
        List<Sugar1> list1 = sugarService.getList1();
        return SugarUtil.getBarData(list1);
    }

    @RequestMapping("/list2")
    public Map getList2(){
        List<Sugar2> list2 = sugarService.getList2();
        return SugarUtil.getPieData(list2);
    }

    @RequestMapping("/list3")
    public Map getList3(){
        List<Sugar1> list3 = sugarService.getList3();
        return SugarUtil.getPieData(list3);
    }

    @RequestMapping("/list4")
    public String getList4(){
        ArrayList<String> list=new ArrayList<>();
        List<Sugar2> list4 = sugarService.getList4();
        list.add("品牌");
        list.add("性别");
        list.add("总金额");
        return SugarUtil.getTablePlayData(list,list4);
    }


}
